package com.xjnt.base.support.admin.entity;

import java.util.List;

import com.xjnt.frameworks.annotation.Entity;
import com.xjnt.frameworks.core.BaseModel;
import com.xjnt.frameworks.plugin.sql.criterion.Restrictions;
import com.xjnt.frameworks.plugin.sql.criterion.SqlCriteria;

/**
 * 区域信息表
 * @author caoyong
 *
 */
@Entity(tableName="sys_area", primaryKey="uuid")
public class Area extends BaseModel<Area> {

	private static final long serialVersionUID = 1L;

	public static final Area me = new Area();
	
	//属性定义
	public static final String PK_ID = "uuid";
	public static final String NAME = "name";
	public static final String CODE = "code";
	public static final String PINYIN = "pinyin";
	public static final String FK_PID = "parentid";
	public static final String LEVEL = "level";
	public static final String CREATETIME = "create_time";
	public static final String UPDATETIME = "update_time";
	
	public Area getParent(){
		return findById(getStr(FK_PID));
	}
	
	public List<Area> getChildren(){
		SqlCriteria criteria = new SqlCriteria(this);
		criteria.add(Restrictions.eq(FK_PID, getStr(PK_ID)));
		return find(criteria.toSql(), getStr(PK_ID));
	}
}
